/**
 * Store User information
 */
Ext.define('Cps.model.User', {
	extend: 'Ext.data.Model',
	fields: [
	     'username',
	     'password',
	     'admin'
	],
	
	hasMany: [{
		model: 'Cps.model.Group',
		name: 'groups',
		foreignKey: 'user_id',
		associationKey: 'groups'
	}],
	
	validations: [
	     { type: 'presence', 'name': 'username' },
	     { type: 'inclusion', 'name': 'admin', list: ['NO', 'YES'] }
	],
	
	proxy: { //CRUD
		type: 'rest',
		url: Cps.Config.Api.user,
		reader: {
			type: 'json',
			root: 'users'
		},
		writer: {
            type: 'json',
            writeAllFields: true,
            root: 'users'
        }
	}
});